package com.cndw.kungfu.model.business;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cndw.kungfu.dao.IPayDao;
import com.cndw.kungfu.domain.Recharge;

@Component
public class IPayManager {

	@Autowired
	private IPayDao dao;

	public int insert(Recharge recharge) {
		try {
			return dao.insert(recharge).intValue();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

	public int selectOrderId(String transactionId,String accountName) {
		try {
			return dao.selectOrderId(transactionId,accountName);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

	public int selectPayGoldSum(long playerId) {
		try {
			return dao.selectPayGoldSum(playerId);
		} catch (NullPointerException e) {
			return 0;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

	public int selectPayGoldSumOnlyQQPay(long playerId) {
		try {
			return dao.selectPayGoldSumOnlyQQPay(playerId);
		} catch (NullPointerException e) {
			return 0;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}	
	public List<Recharge> getRecharge(long playerId, String transactionId, int exchangeType, int beginTime, int endTime, int offset, int limit) {
		try {
			return dao.getRecharge(playerId, transactionId, exchangeType, beginTime, endTime, offset, limit);
		} catch (Exception e) {
			e.printStackTrace();
			return new ArrayList<Recharge>(1);
		}
	}

	public int getRechargeCounts(long playerId, String transactionId, int exchangeType, int beginTime, int endTime) {
		try {
			return dao.getRechargeCounts(playerId, transactionId, exchangeType, beginTime, endTime);
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
	}

	public Recharge selectFirst(long playerId) {
		try {
			return dao.selectFirst(playerId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Recharge selectRecharge(long playerId, int id, int activitybegintime) {
		try {
			return dao.selectRecharge(playerId,id,activitybegintime);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public int selectPeriodPaySum(long playerId, int beginTime, int endTime) {
		try {
			return dao.selectPeriodPaySum(playerId, beginTime, endTime);
		} catch (NullPointerException e) {
			return 0;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

}
